# Top-level Makefile rule for automake
#
# Variable conventions:
#
# _h_api            = API headers that will be installed and included in the distribution
# _cppflags         = flags that will be passed to the C/CXX Preprocessor
# _sources          = sources that will be compiled and included in the distribution
# _built_sources    = files that will be autogenerated by the build system and
#                     will be part of the _SOURCES primary
# _built_nosources  = files that are autogenerated but are not part of the
#                     _SOURCES primary
# _cleanfiles       = files that will be removed by the clean target
#
# Sources, headers, flags, etc... should be added to the respective variables
# with the above suffix, e.g, webcore-specific sources should go to
# webcore_sources, gtk port API and WebCoreSupport parts to webkitgtk_sources,
# etc... The only exceptions are the global variables. See Global Variables
# below.

# Global Variables Reference
# global_cppflags   = CPPFLAGS that apply to all C/C++ files that are built for any project.
# global_cflags     = CFLAGS that apply to all C files that are built for any project.
# global_cxxflags   = CXXFLAGS that apply to all C++ files that are bult for any project.

srcdir = @srcdir@
VPATH = @srcdir@

DISTCHECK_CONFIGURE_FLAGS = \
	--enable-introspection	\
	--enable-gtk-doc \
	--enable-webkit2

# Directory for autogenerated sources
GENSOURCES := $(top_builddir)/DerivedSources
GENSOURCES_JAVASCRIPTCORE := $(top_builddir)/DerivedSources/JavaScriptCore
GENSOURCES_WEBCORE := $(top_builddir)/DerivedSources/WebCore
GENSOURCES_WEBKIT := $(top_builddir)/DerivedSources/webkit
GENSOURCES_WEBKIT2 := $(top_builddir)/DerivedSources/WebKit2
GENSOURCES_WEBKITDOM := $(top_builddir)/DerivedSources/webkitdom
GENSOURCES_PLATFORM := $(top_builddir)/DerivedSources/Platform
GENPROGRAMS := $(top_builddir)/Programs
GENSOURCES_INSPECTOR := $(GENPROGRAMS)/resources/inspector
WebCore := $(srcdir)/Source/WebCore
WebKit := $(srcdir)/Source/WebKit/gtk
WebKit2 := $(srcdir)/Source/WebKit2
pkgconfigdir := $(libdir)/pkgconfig
libwebkitgtkincludedir := $(prefix)/include/webkitgtk-@WEBKITGTK_API_VERSION@

# Libraries and support components
bin_PROGRAMS :=
noinst_PROGRAMS :=
libexec_PROGRAMS :=
noinst_DATA :=
noinst_HEADERS :=
noinst_LTLIBRARIES :=
lib_LTLIBRARIES :=
IDL_BINDINGS :=
TEST_PROGS :=
POFILES :=
PO_LINGUAS :=
USER_LINGUAS :=
USE_LINGUAS :=
MOFILES :=
ALL_MOFILES :=
dom_binding_idls :=
wtf_sources :=
javascriptcore_h_api :=
javascriptcore_cppflags:=
javascriptcore_cflags :=
javascriptcore_sources :=
javascriptcore_built_sources :=
javascriptcore_built_nosources :=
llint_nosources :=
offlineasm_nosources :=
platform_webcore_cppflags :=
platform_cppflags :=
platform_built_sources :=
platform_sources :=
platformgtk_cppflags :=
platformgtk_sources :=
webcore_platform_sources :=
webcore_modules_sources :=
webcore_svg_built_sources :=
webcore_svg_sources :=
webcore_cppflags :=
webcore_sources :=
webcore_libadd :=
webcore_built_sources :=
webcore_built_nosources :=
webcoregtk_sources :=
webcoregtk_cppflags :=
webkitgtk_built_h_api :=
webkitgtk_static_h_api :=
webkitgtk_h_api :=
webkitgtk_sources :=
webkitgtk_cppflags :=
webkitgtk_gdom_built_h_api :=
webkitgtk_gdom_built_sources :=
webkitgtk_built_sources :=
webkitgtk_built_nosources :=
webkit2_h_api :=
webkit2_sources :=
webkit2_built_sources :=
webkit2platform_sources :=
webkit2gtk_h_api :=
webkit2gtk_built_sources :=
webkit2_web_extension_h_api :=
webkit2_plugin_process_sources :=
webkit2_plugin_process_built_sources :=
webkittestrunner_built_sources :=
libwebcoreinternals_built_sources :=
minibrowser_built_sources :=
global_cppflags :=
global_cflags :=
global_cxxflags :=
EXTRA_DIST :=
BUILT_SOURCES :=
CLEANFILES :=
DOMAIN :=
DISTCLEANFILES :=
MAINTAINERCLEANFILES :=
pkgconfig_DATA :=

if ENABLE_INTROSPECTION
gir_DATA :=
typelibs_DATA :=
girdir := $(datadir)/gir-1.0
typelibsdir := $(libdir)/girepository-1.0
endif

# We do not care at all about this implicit built-in make rules,
# disable them to save some build time
%: %.c
%: %.cpp
%: %.o
(%): %
%.out: %
%.c: %.w %.ch
%.tex: %.w %.ch
%:: %,v
%:: RCS/%,v
%:: RCS/%
%:: s.%
%:: SCCS/s.%

global_cppflags += \
	-Wall -W -Wcast-align -Wchar-subscripts -Wreturn-type \
	-Wformat -Wformat-security -Wno-format-y2k -Wundef \
	-Wmissing-format-attribute -Wpointer-arith -Wwrite-strings \
	-Wno-unused-parameter -Wno-parentheses -fno-exceptions \
	-DBUILDING_CAIRO__ \
	-DBUILDING_GTK__

if ENABLE_WEBKIT2
global_cppflags += \
	-DBUILDING_WEBKIT2__

endif

global_cxxflags += \
	-fno-rtti

# Read the feature defines file, that's created by generate-feature-defines-files
# during configuration (SetupWebKitFeatures.m4).
feature_defines := $(shell cat WebKitFeatures.txt)

# -no-undefined required for building DLLs on Windows
# It breaks the build on other platforms, so we use it conditionally
if OS_WIN32
no_undefined = -no-undefined
version_script = -export-symbols-regex "^(webkit_|k?JS).*"
endif

if OS_GNU
version_script = -Wl,--version-script,$(srcdir)/Source/autotools/symbols.filter
endif

if ENABLE_COVERAGE
global_cppflags += \
	-DGCC_GENERATE_TEST_COVERAGE_FILES \
	-DGCC_INSTRUMENT_PROGRAM_FLOW_ARCS
endif

# Default to outputting demangled symbols in case of reporting unresolved references or similar.
# Using AM_LDFLAGS would be more appropriate here, but these are not used at all when linking installable libraries
# like libwebkitgtk and libwebkit2gtk, so appending the linker flag to the LDFLAGS variable is done instead.
LDFLAGS += -Wl,--no-demangle

EXTRA_DIST += \
	$(srcdir)/Source/autotools/symbols.filter \
	$(srcdir)/Source/WebKit/LICENSE

# Include module makefiles
include Source/WTF/GNUmakefile.am
include Source/JavaScriptCore/GNUmakefile.am
include Source/Platform/GNUmakefile.am 
include Source/WebCore/GNUmakefile.am
include Source/WebCore/bindings/gobject/GNUmakefile.am
include Source/WebCore/platform/gtk/po/GNUmakefile.am
include Source/WebKit/gtk/GNUmakefile.am
include Tools/GNUmakefile.am

include Source/WebKit2/GNUmakefile.am
include Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
include Tools/MiniBrowser/gtk/GNUmakefile.am
include Tools/WebKitTestRunner/GNUmakefile.am
include Source/ThirdParty/ANGLE/GNUmakefile.am
include Source/ThirdParty/gtest/GNUmakefile.am
include Source/ThirdParty/leveldb/GNUmakefile.am
include Tools/TestWebKitAPI/GNUmakefile.am
# [GTK] Refactor the translations now that we have webkit2
# https://bugs.webkit.org/show_bug.cgi?id=55153

# Autogenerated sources
BUILT_SOURCES += \
	$(javascriptcore_built_sources) \
	$(javascriptcore_built_nosources) \
	$(platform_built_sources) \
	$(webcore_built_sources) \
	$(webcore_built_nosources) \
	$(webcore_svg_built_sources) \
	$(webkitgtk_built_sources) \
	$(webkitgtk_built_nosources) \
	$(webkit2_built_sources) \
	$(webkit2gtk_built_sources) \
	$(webkit2_plugin_process_built_sources)

DISTCLEANFILES += \
	$(CLEANFILES) \
	$(builddir)/doltcompile \
	$(builddir)/doltlibtool \
	$(builddir)/WebKitFeatures.h \
	$(builddir)/WebKitFeatures.txt

MAINTAINERCLEANFILES += \
	$(CLEANFILES) \
	$(builddir)/doltcompile \
	$(builddir)/doltlibtool \
	$(srcdir)/aconfig.h.in \
	$(srcdir)/Source/autotools/config.* \
	$(srcdir)/Source/autotools/compile \
	$(srcdir)/Source/autotools/depcomp \
	$(srcdir)/Source/autotools/install-sh \
	$(srcdir)/Source/autotools/missing \
	$(srcdir)/configure \
	$(srcdir)/GNUmakefile.in \
	$(srcdir)/INSTALL \
	$(srcdir)/README \
	$(top_builddir)/config.*

# Older automake versions (1.7) place Plo files in a different place so we need
# to create the output directory manually.
all-local: stamp-po
	$(MKDIR_P) $(top_builddir)/$(DEPDIR)/DerivedSources

# remove built sources and program directories
clean-local:
	-rm -rf $(GENPROGRAMS)

maintainer-clean-local: distclean-local
distclean-local:
	-rm -rf $(GENSOURCES) $(GENPROGRAMS)

dist-hook: doc-dist-hook
doc-dist-hook: docs-build.stamp
	cp $(WebKit)/NEWS $(distdir)
if ENABLE_WEBKIT1
	@mkdir -p $(distdir)/Documentation/webkitgtk/html
	@mkdir -p $(distdir)/Documentation/webkitgtk/tmpl
	@-cp ./Documentation/webkitgtk/tmpl/*.sgml $(distdir)/Documentation/webkitgtk/tmpl
	@cp ./Documentation/webkitgtk/html/* $(distdir)/Documentation/webkitgtk/html
endif
if ENABLE_WEBKIT2
	@mkdir -p $(distdir)/Documentation/webkit2gtk/html
	@mkdir -p $(distdir)/Documentation/webkit2gtk/tmpl
	@-cp ./Documentation/webkit2gtk/tmpl/*.sgml $(distdir)/Documentation/webkit2gtk/tmpl
	@cp ./Documentation/webkit2gtk/html/* $(distdir)/Documentation/webkit2gtk/html
endif
